Skip to content

fix(client): fail fast on 202 after SSE reconnect exhaustion#2099

Open
he-yufeng wants to merge 3 commits into
modelcontextprotocol:mainfrom
he-yufeng:fix/streamable-http-sse-reconnect-exhaustion
Open

fix(client): fail fast on 202 after SSE reconnect exhaustion#2099
he-yufeng wants to merge 3 commits into
modelcontextprotocol:mainfrom
he-yufeng:fix/streamable-http-sse-reconnect-exhaustion

Conversation

@he-yufeng
Copy link
Copy Markdown

@he-yufeng he-yufeng commented May 15, 2026

Summary

  • raise the default standalone SSE reconnection budget from 2 attempts to 10
  • keep track of standalone SSE reconnection exhaustion and fail fast when a later request receives 202 Accepted, because that response path depends on the dead standalone SSE channel
  • still allow later requests with direct JSON or per-request SSE responses to succeed, matching the consumer e2e contract
  • include a fallback HTTP status in SSE-open errors when statusText is empty

Fixes #2098.

To verify

  • pnpm --filter @modelcontextprotocol/client test -- streamableHttp.test.ts
  • pnpm --filter @modelcontextprotocol/test-e2e exec vitest run scenarios/transport-http.test.ts
  • pnpm --filter @modelcontextprotocol/client typecheck
  • pnpm --filter @modelcontextprotocol/client lint
  • pnpm --filter @modelcontextprotocol/client build
  • pnpm changeset status --since upstream/main
  • git diff --check

The latest push also passed the repo pre-push hook: repo-wide build, typecheck, and lint.

@he-yufeng he-yufeng requested a review from a team as a code owner May 15, 2026 18:07
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 15, 2026

🦋 Changeset detected

Latest commit: 7af5901

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@modelcontextprotocol/client Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 15, 2026

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/client@2099

@modelcontextprotocol/codemod

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/codemod@2099

@modelcontextprotocol/server

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/server@2099

@modelcontextprotocol/express

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/express@2099

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/fastify@2099

@modelcontextprotocol/hono

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/hono@2099

@modelcontextprotocol/node

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/node@2099

commit: 7af5901

@he-yufeng
Copy link
Copy Markdown
Author

The only remaining red check appears to be a Cloudflare Workers / Miniflare flake on Node 22: test/server/cloudflareWorkers.test.ts failed with SdkError: Error POSTing to endpoint: Error: Network connection lost, while the rest of that integration shard reported 422 passed tests. I tried to rerun the failed job, but GitHub rejected it because I do not have repository admin rights. Could a maintainer rerun est (22) when convenient?

@BossChaos

This comment was marked as abuse.

@he-yufeng
Copy link
Copy Markdown
Author

Rebased onto current main and force-pushed 91c515f. Local validation: changeset status shows @modelcontextprotocol/client patch; client streamableHttp.test.ts passed with 54 tests; client typecheck and lint passed; git diff --check passed. Note: my first Vitest command used a repo-root-relative path under the filtered package and found no files; reran with the package-relative path.

@he-yufeng he-yufeng force-pushed the fix/streamable-http-sse-reconnect-exhaustion branch from 3597345 to 91c515f Compare May 27, 2026 10:30
@he-yufeng he-yufeng changed the title fix(client): fail fast after SSE reconnect exhaustion fix(client): fail fast on 202 after SSE reconnect exhaustion May 30, 2026
@he-yufeng
Copy link
Copy Markdown
Author

Rebased on the new e2e suite and adjusted the failure boundary in 7af5901.

The previous version failed every future request once the standalone GET SSE reconnect budget was exhausted. The new consumer e2e test expects direct-response requests to keep working after that failure, so the PR now only fails fast when a later request gets 202 Accepted, where the response would otherwise be delivered through the dead standalone SSE channel and time out silently.

Local validation:

  • pnpm --filter @modelcontextprotocol/client test -- streamableHttp.test.ts
  • pnpm --filter @modelcontextprotocol/test-e2e exec vitest run scenarios/transport-http.test.ts
  • pnpm --filter @modelcontextprotocol/client typecheck
  • pnpm --filter @modelcontextprotocol/client lint
  • pnpm --filter @modelcontextprotocol/client build
  • pnpm changeset status --since upstream/main
  • git diff --check

The push also passed the repo pre-push hook: repo-wide build, typecheck, and lint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

StreamableHTTPClientTransport: 2-retry SSE reconnect ceiling + silent-success after exhaustion

2 participants